package com.yc.cloud.admin.enums;

import lombok.Getter;

/**
 * 触发源枚举
 *
 * @author kinggu
 * @since 2025-10-10
 */
@Getter
public enum TriggerSourceEnum {
    /**
     * 定时任务
     */
    SCHEDULE("SCHEDULE", "定时任务"),
    
    /**
     * 告警触发
     */
    ALARM("ALARM", "告警触发"),
    
    /**
     * 用户手动
     */
    USER("USER", "用户手动"),
    
    /**
     * API调用
     */
    API("API", "API调用");

    private final String code;
    private final String desc;

    TriggerSourceEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取枚举
     */
    public static TriggerSourceEnum fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (TriggerSourceEnum source : values()) {
            if (source.code.equals(code)) {
                return source;
            }
        }
        return null;
    }
}

